package com.ityshow.uaa.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A ClientDetails.
 */
@Entity
@Table(name = "client_details")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "clientdetails")
public class ClientDetails implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Column(name = "app_id", nullable = false)
    private String appId;

    @Column(name = "resource_ids")
    private String resourceIds;

    @Column(name = "app_secret")
    private String appSecret;

    @Column(name = "scopt")
    private String scopt;

    @Column(name = "scope")
    private String scope;

    @Column(name = "grant_types")
    private String grantTypes;

    @Column(name = "redirect_url")
    private String redirectUrl;

    @Column(name = "authorities")
    private String authorities;

    @Column(name = "access_token_valid_dity")
    private String accessTokenValidDity;

    @Column(name = "refresh_token_validity")
    private String refreshTokenValidity;

    @Column(name = "additional_information")
    private String additionalInformation;

    @Column(name = "auto_approve_scopes")
    private String autoApproveScopes;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAppId() {
        return appId;
    }

    public ClientDetails appId(String appId) {
        this.appId = appId;
        return this;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getResourceIds() {
        return resourceIds;
    }

    public ClientDetails resourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
        return this;
    }

    public void setResourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public ClientDetails appSecret(String appSecret) {
        this.appSecret = appSecret;
        return this;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getScopt() {
        return scopt;
    }

    public ClientDetails scopt(String scopt) {
        this.scopt = scopt;
        return this;
    }

    public void setScopt(String scopt) {
        this.scopt = scopt;
    }

    public String getScope() {
        return scope;
    }

    public ClientDetails scope(String scope) {
        this.scope = scope;
        return this;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getGrantTypes() {
        return grantTypes;
    }

    public ClientDetails grantTypes(String grantTypes) {
        this.grantTypes = grantTypes;
        return this;
    }

    public void setGrantTypes(String grantTypes) {
        this.grantTypes = grantTypes;
    }

    public String getRedirectUrl() {
        return redirectUrl;
    }

    public ClientDetails redirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
        return this;
    }

    public void setRedirectUrl(String redirectUrl) {
        this.redirectUrl = redirectUrl;
    }

    public String getAuthorities() {
        return authorities;
    }

    public ClientDetails authorities(String authorities) {
        this.authorities = authorities;
        return this;
    }

    public void setAuthorities(String authorities) {
        this.authorities = authorities;
    }

    public String getAccessTokenValidDity() {
        return accessTokenValidDity;
    }

    public ClientDetails accessTokenValidDity(String accessTokenValidDity) {
        this.accessTokenValidDity = accessTokenValidDity;
        return this;
    }

    public void setAccessTokenValidDity(String accessTokenValidDity) {
        this.accessTokenValidDity = accessTokenValidDity;
    }

    public String getRefreshTokenValidity() {
        return refreshTokenValidity;
    }

    public ClientDetails refreshTokenValidity(String refreshTokenValidity) {
        this.refreshTokenValidity = refreshTokenValidity;
        return this;
    }

    public void setRefreshTokenValidity(String refreshTokenValidity) {
        this.refreshTokenValidity = refreshTokenValidity;
    }

    public String getAdditionalInformation() {
        return additionalInformation;
    }

    public ClientDetails additionalInformation(String additionalInformation) {
        this.additionalInformation = additionalInformation;
        return this;
    }

    public void setAdditionalInformation(String additionalInformation) {
        this.additionalInformation = additionalInformation;
    }

    public String getAutoApproveScopes() {
        return autoApproveScopes;
    }

    public ClientDetails autoApproveScopes(String autoApproveScopes) {
        this.autoApproveScopes = autoApproveScopes;
        return this;
    }

    public void setAutoApproveScopes(String autoApproveScopes) {
        this.autoApproveScopes = autoApproveScopes;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ClientDetails clientDetails = (ClientDetails) o;
        if (clientDetails.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, clientDetails.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "ClientDetails{" +
            "id=" + id +
            ", appId='" + appId + "'" +
            ", resourceIds='" + resourceIds + "'" +
            ", appSecret='" + appSecret + "'" +
            ", scopt='" + scopt + "'" +
            ", scope='" + scope + "'" +
            ", grantTypes='" + grantTypes + "'" +
            ", redirectUrl='" + redirectUrl + "'" +
            ", authorities='" + authorities + "'" +
            ", accessTokenValidDity='" + accessTokenValidDity + "'" +
            ", refreshTokenValidity='" + refreshTokenValidity + "'" +
            ", additionalInformation='" + additionalInformation + "'" +
            ", autoApproveScopes='" + autoApproveScopes + "'" +
            '}';
    }
}
